//二分查找

//好好学学efcz函数的思想
function efcz(nums,target,result){
    let left=0,rigth=nums.length-1,ans=nums.length
    while(rigth>=left){
        let mid = Math.floor((left+rigth)/2)
        if(nums[mid]>target||(result==true&&nums[mid]>=target)){
             rigth = mid-1
             ans = mid
        }else{
            left = mid+1
        }
    }
    return ans
}


 var searchRange = function(nums, target) {
    let ans = [-1,-1]
    let leftIdx = efcz(nums,target,true)
    let rigthIdx = efcz(nums,target,false)-1
    if(nums[leftIdx]==target&&nums[rigthIdx]==target){
        ans = [leftIdx,rigthIdx]
    }
    return ans
} 


    